package event_handlers

import (
	"fmt"
	"go-ddd-ecommerce/internal/domain/events"
)

// PointsCalculationHandler 积分计算处理器
type PointsCalculationHandler struct{}

func NewPointsCalculationHandler() *PointsCalculationHandler {
	return &PointsCalculationHandler{}
}

func (h *PointsCalculationHandler) Handle(event events.DomainEvent) error {
	switch e := event.(type) {
	case *events.OrderCreatedEvent:
		// 计算积分：每消费1元获得1积分
		points := int(e.TotalAmount)
		fmt.Printf("🎯 积分计算: 用户 %s 获得 %d 积分\n", e.UserID, points)
		// 实际项目中这里会调用积分服务
		return nil
	default:
		return nil
	}
}
